<?xml version="1.0" encoding="ISO-8859-1" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" version="2.0">
	<jsp:directive.page contentType="text/html; charset=ISO-8859-1"
		pageEncoding="ISO-8859-1" session="false" />
	<jsp:output doctype-root-element="html"
		doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
		omit-xml-declaration="true" />
	<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<title>Product List</title>
			<link href="/static/base.css" rel="stylesheet" type="text/css"></link>
		</head>
		<body >
		
			<script src="/js/jquery-1.7.2.min.js">""</script>
			<script src="/js/browse.buy.js">""</script>
			
		
				<c:choose>
					<c:when test="${userSession.type == 'User'}">
						<jsp:include page="/WEB-INF/jsp/page.header.jsp"></jsp:include>
					</c:when>
					<c:otherwise>
					 	<jsp:include page="/WEB-INF/jsp/admin/header.jsp"></jsp:include>
					</c:otherwise>
				</c:choose>	
			
			<div style="text-align: left">
				<h1>List of Product</h1>
				
				<c:choose>
				   <c:when test="${not empty products}">
						<table>
							<tr class="headerTable">
								<td>&#160;</td>
								<td>Category</td>
								<td>Name</td>
								<td>Picture</td>
								<td>Price</td>
								<td>Seller's Comment</td>
								<td>&#160;</td>
							</tr>
							<c:forEach var="product" items="${products}" varStatus="rowCounter">
								 <c:choose>
									<c:when test="${rowCounter.count % 2 == 0}">
										<c:set var="rowStyle" scope="page" value="odd" />
									</c:when>
									<c:otherwise>
										<c:set var="rowStyle" scope="page" value="even" />
									</c:otherwise>
								</c:choose>
								<tr class="{rowStyle}">
									<td>${rowCounter.count}</td>
									<td>${fn:escapeXml(product.category)}</td>
									<td><a href="/service/product/detail?id=${product.productId}">${fn:escapeXml(product.name)}</a></td>
									<td>${fn:escapeXml(product.picture)}</td>
									<td><fmt:formatNumber type="number" pattern="###,###.00" value="${product.price}" /></td>
									<td>${fn:escapeXml(product.comment)}</td>
			
									<td>
										<button onclick='browse.buy(${product.key.id})'>Buy</button>		
																
									</td>
								</tr>
							</c:forEach>
						</table>	
					</c:when>
					<c:otherwise>
					 	<p>You do not have any product yet.</p>
					</c:otherwise>
				</c:choose>												
			</div>
		</body>
	</html>
</jsp:root>